/**
 * 匿名对象
 */

public class AnonymousObject {
    public static void main(String[] args) {
        User john = new User();
        john.usePhone(new Phone());
    }

}

class User {
    public void usePhone(Phone phone){
        phone.sendEmail();
        phone.playGame();
    }
}


class Phone {
    public void sendEmail() {
        System.out.println("发邮件");
    }

    public void playGame() {
        System.out.println("玩游戏");
    }
}
